/*
kevx@09/12/2011
*/
(function() {
  
    String.prototype.trim = function(){   
      return this.replace(/(^\s*)|(\s*$)/g,"");   
    }

    function getSerialNumber(objService, device) {
        var results = objService.ExecQuery("SELECT * FROM " + device);
        if(results != null) {
            return String.valueOf(results.ItemIndex(0).Signature);
        } else {
            return "";
        }
    }

    function initWmi() {   
        var objLocator = WScript.CreateObject("WbemScripting.SWbemLocator");
        var objService  = objLocator.ConnectServer(".", "root\\cimv2");
        objService.Security_.ImpersonationLevel = 3;
        return objService;
    }

    var objService = initWmi();
    var str = new String();
    str += "DISK_SERIAL: " + getSerialNumber(objService, "Win32_DiskDrive") + "\n";
    //str += "BIOS_SERIAL: " + getSerialNumber(objService, "Win32_BIOS") + "\n";
    //str += "BOARD_SERIAL: " + getSerialNumber(objService, "Win32_BaseBoard") + "\n";

    WScript.Echo(str);

    objService = null;

})();
